import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import { Comment } from './comment.entity';
import { IsOptional } from 'class-validator';

@Entity()
export class CommentPicture {
  @PrimaryGeneratedColumn()
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', nullable: false})
  comment_id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 255, nullable: false})
  pic_url: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'tinyint', nullable: false, default: 5})
  sort_order: number;

  @ManyToOne(type => Comment, comment => comment.commentPicture)
  @JoinColumn({
    name:"comment_id"
  })
  comment: Comment;
}
